﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WickedFlame.Core.Shapes;
using System.Windows;

namespace WickedFlame.Core.State
{
    [Serializable]
    public class TextMemento : ShapeMemento
    {
        string text;
        string font;
        double fontSize;
        Point point;

        public override void SaveProperties(VectorShape shape)
        {
            base.SaveProperties(shape);

            TextShape c = shape as TextShape;
            if (c != null)
            {
                text = c.Text;
                font = c.FontFamily.ToString();
                fontSize = c.FontSize;
                point = c.Point;
            }
        }

        public override void ResetProperties(VectorShape shape)
        {
            base.ResetProperties(shape);

            TextShape c = shape as TextShape;
            if (c != null)
            {
                c.Text = text;
                c.FontFamily = new System.Windows.Media.FontFamily(font);
                c.FontSize = fontSize;
                c.Point = point;
            }
        }

        public override VectorShape GenerateShape()
        {
            var shape = new TextShape();
            shape.ResetState(this);

            return shape;
        }
    }
}
